home *** CD-ROM | disk | FTP | other *** search
/ Merciful 2 / Merciful - Disc 2.iso / software / h / hispeedv6.3reg.lha / HiSpeed / arexx / Address.rexx < prev    next >
OS/2 REXX Batch file  |  1993-08-11  |  6KB  |  219 lines

  1. /* Print address labels. The label carrier (by 'Zweckform') is     */
  2. /* supposed to look like this:                                     */
  3. /*                                                                 */
  4. /*     ----------------------------------------------              */
  5. /*     |                                             | top offfset */
  6. /*     |---------------------------------------------|             */
  7. /*     |              |              |               |             */
  8. /*     |              |              |               | 3 columns   */
  9. /*     |              |              |               | 8 rows      */
  10. /*     |---------------------------------------------|             */
  11. /*     |              |              |               |             */
  12. /*     |              |              |               |             */
  13. /*     //             //             //              //            */
  14. /*                                                                 */
  15. /*                                                                 */
  16. /*     //             //             //              //            */
  17. /*     |              |              |               |             */
  18. /*     |---------------------------------------------|             */
  19. /*     |              |              |               |             */
  20. /*     |              |              |               |             */
  21. /*     |              |              |               |             */
  22. /*     |---------------------------------------------|             */
  23. /*     |              |              |               |             */
  24. /*     |              |              |               |             */
  25. /*     |              |              |               |             */
  26. /*     |---------------------------------------------|             */
  27. /*     |              |              |               |             */
  28. /*     |              |              |               |             */
  29. /*     |              |              |               |             */
  30. /*     |---------------------------------------------|             */
  31. /*     |                                             | bottom      */
  32. /*     ----------------------------------------------  margin      */
  33.  
  34. columns = 3     /* number of labels/line                           */
  35. rows    = 8     /* number of lines                                 */
  36. toffset = 5     /* top border    (must be at least 5 mm)           */
  37. boffset = 5     /* bottom margin (must be at least 5-7 mm)         */
  38. paperx  = 210   /* paper width  [mm]                               */
  39. papery  = 298   /* paper height [mm]                               */
  40.  
  41. /* ----------------------------------------------------------------*/
  42.  
  43. options results
  44. shell
  45.  
  46. address HISPEED.1
  47.  
  48. SET BOOK     OFF
  49. SET HEADER   OFF          /* 5 mm still remain unusable :-(       */
  50. SET DX 7                  /* i.e. left/right border = 3.5 mm      */
  51. SET DY 10
  52.  
  53. 'SET PAPERX' 210 + 7      /* add 7 mm for right border            */
  54. 'SET PAPERY' papery + 10  /* compensate for borders               */
  55.  
  56. SET SEPARATE OFF
  57.  
  58. SET LAYOUTX columns       /* two columns/label                    */
  59. SET LAYOUTY rows
  60.  
  61. SET QUALITY LQ
  62.  
  63. SET TOP    toffset + 5
  64. SET BOTTOM boffset
  65. SET LEFT   7
  66. SET RIGHT  7
  67.  
  68. /* consider position of DeskJet's middle platen (used as guide): */
  69.  
  70. QUERY BLOCKX  /* maximum entry length [characters] incl. CR */
  71.  
  72. blockx  = trunc(RESULT) - 1
  73. labels  = columns * rows
  74.  
  75. say ""
  76. say " This script does support printing on labels by Zweckform "
  77. say " (70 * 50.8 mm, on a 3 x 5 carrier).                      "
  78. say ""
  79. say " Tell me the number of the 1st label you want to print or "
  80. say " 0 to exit. The sheet's top left label is considered to be"
  81. say " 1, its right neighbour 2, the last label is " || labels
  82.  
  83. pull first
  84.  
  85. if (first < 1) | (first > labels) then do
  86.  
  87.   say " Done (please close window)."
  88.   exit
  89.  
  90. end
  91.  
  92. say " Enter file to scan (addresses separated by *):"
  93. pull database
  94.  
  95. QUERY BLOCKY           /* how many lines can be printed on a label ? */
  96. maxEntries = RESULT
  97.  
  98. /* remove 'waste' of last run (if any) */
  99.  
  100. shell
  101. DELETE ">NIL:" "T:LABELTEXT"
  102. address HISPEED.1
  103.  
  104. /* open 'label' file (will become output file) */
  105.  
  106. R = open('txt', "T:LABELTEXT", 'WRITE')
  107.  
  108. if (R = 0) then do
  109.   SET WARN "Error - couldn't create temporary file"
  110.   exit
  111. end
  112.  
  113. /* open input file (database) */
  114.  
  115. R = Open('data', database, 'READ')
  116.  
  117. if (R = 0) then do
  118.   SET WARN "Error - couldn't open read file"
  119.   exit
  120. end
  121.  
  122. /* 'jump' to first label */
  123.  
  124. if (first > 1) then do
  125.   do piece = 0 to (first - 2)
  126.     do n = 1 to maxEntries
  127.         R = writeln('txt', "")
  128.     end
  129.   end
  130. end
  131.  
  132. /* Read database */
  133.  
  134. piece     = first - 1  /* count used labels   */
  135. terminate = 0
  136.  
  137. do while (terminate = 0)
  138.  
  139.   say " reading label Nº" (piece + 1) "..."
  140.  
  141.   if EOF('data') then
  142.  
  143.       terminate = 1
  144.  
  145.   else do
  146.  
  147.     entries = 0
  148.  
  149.     /* read % store next label (until *) */
  150.  
  151.     do while (entries < maxEntries)
  152.  
  153.         line = readln('data')
  154.  
  155.         if (line = "*") then
  156.  
  157.             break
  158.  
  159.         else do
  160.  
  161.             /* use bold printing for first line */
  162.  
  163.             if (entries = 0) then
  164.                 R = writeln('txt', '' || line || '')
  165.             else
  166.                 R = writeln('txt', line)
  167.         end
  168.  
  169.         entries = entries + 1
  170.  
  171.         /* empty line between name & rest of address */
  172.  
  173.         if (entries = 1) then do
  174.  
  175.             R = writeln('txt', '')
  176.             entries = 2
  177.  
  178.         end
  179.  
  180.     end
  181.  
  182.     /* 'fill' empty lines of labels */
  183.  
  184.     do while (entries < maxEntries)
  185.  
  186.       entries = entries + 1
  187.       R = writeln('txt', "")
  188.  
  189.     end
  190.  
  191.     piece = piece + 1
  192.  
  193.   end
  194.  
  195. end
  196.  
  197. R = close('txt')
  198. R = Close('data')
  199.  
  200. CLR
  201. SET FILE "T:LABELTEXT"
  202.  
  203. /* anything to print ? */
  204.  
  205. QUERY JOBS
  206.  
  207. if RESULT = 0 then
  208.  
  209.   SET WARN " Couldn't set files. Maybe empty ?!"
  210.  
  211. else do
  212.  
  213.   SET ASK " Proceed with printing (Y/N) ?"
  214.   if RESULT = 1 then
  215.       PRINT
  216. end
  217.  
  218. say " Ready (please close window)."
  219.